﻿//-----------------------------------------------------------------------
// <copyright file="CellFactory.cs" company="cx studio">
//     Copyright (c) cx studio. All rights reserved.
// </copyright>
// <author>Xi Chen</author>
//-----------------------------------------------------------------------
namespace CentralFoveaLib.Brain
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;

    public class CellFactory
    {
        public CellSet BuildCellSet(int level)
        {
            CellSet cellSet = new CellSet();
            cellSet.AixCells = BuildCells(level);
            cellSet.MindCells = BuildMind(level);
            return cellSet;
        }

        public IDictionary<int, List<Cell>> BuildMind(int level)
        {
            IDictionary<int, List<Cell>> dict = new Dictionary<int,List<Cell>>();
            for (int i = 0; i < level; i++)
			{
			    dict[i] = CreateCell(256);
			}
            return dict;
        }

        public List<List<Cell>> BuildCells(int level)
        {
            List<List<Cell>> cells = new List<List<Cell>>(5);
            for (int i = 0; i < level; i++)
            {
                var line = new List<Cell>();
                line = CreateCell(32, 32);
                cells.Add(line);
            }

            return cells;
        }

        private List<Cell> CreateCell(int l)
        {
            var line = new List<Cell>();
            for (int i = 0; i < l; i++)
            {
                line.Add(new Cell());
            }
            return line;
        }

        private List<Cell> CreateCell(int x,int y)
        {
            var line = new List<Cell>();
            for (int i = 0; i < x; i++)
            {
                for (int j = 0; j < y; j++)
                {
                    line.Add(new Cell() {X=j,Y=i });
                }
            }
            return line;
        }
    }
}
